﻿using SimplePersonApp.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace SimplePersonApp.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            List<PersonViewModel> model = new List<PersonViewModel>(); 

            PeopleDbContext tredb = new PeopleDbContext();

            List<Person> people = tredb.Person.ToList();
                //.Where(n => n.FirstName == "trey" ||  n.FirstName == "donny").ToList();

            foreach (Person x in people)
            {
                PersonViewModel test = new PersonViewModel();
                test.FirstName = x.FirstName;
                test.LastName = x.LastName;
                test.BirthDate = x.BirthDate;

                model.Add(test);
            }


            //Person donny = tredb.Person.FirstOrDefault(n => n.FirstName == "donny");

            //model.FirstName = tre.FirstName;
            //model.LastName = tre.LastName;
            //model.BirthDate = tre.BirthDate;


            return View(model);
        }

        public ActionResult About()
        {
            ViewBag.Message = "Your application description page.";

            return View();
        }

        public ActionResult Contact()
        {
            ViewBag.Message = "Your contact page.";

            return View();
        }
    }
}